<template>
  <div class="gameswipes">
    <div class="gameswipes-box">
      <ul :style="{ marginLeft: lefts + 'rem' }">
        <li
          v-for="(item, index) in img"
          @mouseenter="moHover"
          @mouseout="outMous"
          :key="index"
        >
          <img :src="item" alt="" />
        </li>
      </ul>
    </div>

    <div
      class="gameswipes-left"
      @click="changLeft"
      @mouseenter="moHover"
      :class="{ displaylabe: labeDis, nonelabe: lefts == 0 }"
    >
      <img src="../../assets/img/right.svg" alt="" />
    </div>
    <div
      class="gameswipes-right"
      @click="changRight"
      @mouseenter="moHover"
      :class="{ displaylabe: labeDis, nonelabe: lefts == max }"
    >
      <img src="../../assets/img/right.svg" alt="" />
    </div>
  </div>
</template>

<script>
import { showGameMessage } from "../../network/showGame";

export default {
  name: "GameSwipes",
  props: {
    listt: {},
  },
  data() {
    return {
      lefts: 0,
      labeDis: false,
      labeDis2: true,
      img: "",
      max: "",
    };
  },
  created() {
    this.getId();
  },

  methods: {
    getId() {
      let gid = window.location.pathname.split("/")[2];
      showGameMessage(gid, this.$Cookie.get("userid")).then((res) => {
        this.list = res.data.data;
        this.img = this.list.grImg.split(",");
        this.max = (this.img.length - 1) * -5;
      });
    },

    changLeft() {
      this.lefts += 5;
    },

    changRight() {
      this.lefts -= 5;
    },

    moHover() {
      this.labeDis = true;
    },

    outMous() {
      this.labeDis = false;
    },
  },
};
</script>

<style>
.gameswipes {
  flex: 1.7;
  position: relative;
}

.gameswipes-box {
  width: 5rem;
  overflow: hidden;
  border-radius: 10px;
}

.gameswipes ul {
  width: 5rem;
  list-style: none;
  display: flex;
  transition: all 1s;
  cursor: pointer;
}

.gameswipes ul li {
  width: 5rem;
  height: 2.7rem;
}

.gameswipes ul li img {
  width: 5rem;
  height: 2.7rem;
}

.gameswipes-left {
  position: absolute;
  top: 50%;
  left: -0.15rem;
  transform: rotate(180deg);
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background-color: #fff;
  z-index: 999;
  display: none;
  cursor: pointer;
}

.gameswipes-left img,
.gameswipes-right img {
  width: 100%;
  height: 100%;
}

.gameswipes-right {
  position: absolute;
  top: 50%;
  right: -0.1rem;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background-color: #fff;
  z-index: 999;
  display: none;
  cursor: pointer;
}

.displaylabe {
  display: block;
}

.nonelabe {
  display: none;
}
</style>